package com.edu.buservice.biz.shared.impl;

import com.edu.buservice.biz.TenantManger;
import com.edu.buservice.biz.model.dto.TenantInfoDTO;
import com.edu.buservice.facade.facade.TenantFacade;
import com.edu.buservice.facade.model.response.TenantDTO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @program: KQAIA
 * @description:
 * @author: 无恙
 * @create: 2025-03-17 11:42
 **/

@Service
@DubboService(interfaceClass = TenantFacade.class)
public class TenantFacadeImpl implements TenantFacade {

	@Autowired
	private TenantManger tenantManger;

	@Override
	public TenantDTO getTenantById(String tenantId) {
		TenantInfoDTO tenantInfoByTenantId = tenantManger.getTenantInfoByTenantId(tenantId);
		if(Objects.nonNull(tenantInfoByTenantId)){
			TenantDTO tenantDTO = new TenantDTO();
			tenantDTO.setTenantId(tenantInfoByTenantId.getTenantId());
			tenantDTO.setTenantName(tenantInfoByTenantId.getName());
			return tenantDTO;
		}
		return null;
	}

	@Override
	public Boolean updateToken(String tenantId, Long token) {
		return tenantManger.updateTenantToken(tenantId,token);

	}
}
